<?php


namespace App\Services;


use App\Models\Game\VersionEvent;
use App\Utils\MyLog;

class VersionEventService
{
    public function refreshPackageNos() //刷新这个版本下面的包列表
    {
        $versionEventList = VersionEvent::query()->with(['channel'=>function($channel){
            $channel->with('packages');
        }])->where('package_model',2)->get();
        MyLog::info('包号信息'.json_encode($versionEventList));
        foreach($versionEventList as $versionEvent){
            $packageNoList = [];
            $channel = $versionEvent->channel;
            foreach ($channel->packages as $package){
                $packageNoList[] = $package->package_no;
            }
            $versionEvent->package_nos = json_encode($packageNoList,JSON_UNESCAPED_UNICODE );
            $versionEvent->updated_at = date("Y-m-d H:i:s");
            $versionEvent->save();
        }
    }

}
